package days31.title222;

class Solution {
    int count = 0;
    public int countNodes(TreeNode root) {
        dfs(root);
        return count;
    }

    private void dfs(TreeNode root) {
        if (root!=null){
            count++;
            dfs(root.right);
            dfs(root.left);
        }
    }
}